/*
 * @(#)IsConnent.java	 Mar 7, 2012
 *
 * Copyright 2004-2012 WXXR Network Technology Co. Ltd. 
 * All rights reserved.
 * 
 * WXXR PROPRIETARY/CONFIDENTIAL.
 */

package com.ykdl.member.kid.util;

import android.content.Context;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import com.ykdl.member.base.QLog;
/**
 * 
 * 判断联网的工具类
 *
 * @since 1.0
 */
public class IsConnent {

	public static boolean isConnect(Context context) { 
        // 获取手机所有连接管理对象（包括对wi-fi,net等连接的管理） 
    try { 
        ConnectivityManager connectivity = (ConnectivityManager) context 
                .getSystemService(Context.CONNECTIVITY_SERVICE); 
        if (connectivity != null) { 
            // 获取网络连接管理的对象 
            NetworkInfo info = connectivity.getActiveNetworkInfo(); 
            if (info != null&& info.isConnected()) { 
                // 判断当前网络是否已经连接 
                //if (info.getState() == NetworkInfo.State.CONNECTED) { 
                    return true; 
                //} 
            } 
        } 
    } catch (Exception e) { 
// TODO: handle exception 
    QLog.debug("error",e.toString()); 
} 
        return false; 
    } 
	
	public static boolean isOpenGPS(Context context){
		LocationManager locationManager = (LocationManager)context.  
		getSystemService(Context.LOCATION_SERVICE);  
		return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
	}
	
	public static boolean isMapAddOn(){
		//used baidu map  return true
//		try {  
//		    Class.forName("com.google.android.maps.MapActivity"); 
//		    return true;
//		} catch (Exception e) {       
//		    return false;  
//		}  
		return true;
	}
}
